<?php echo $this->render('/manage/header.phtml');?>
<script type="text/javascript" src="<?php echo APPLICATION_PUBLIC; ?>/js/admin/articleList.js"></script>
</head>
<body>
<div id="body-wrapper">
<?php echo $this->render('/manage/sidebar.phtml');?>
<?php
	$tableInfo = Zend_Registry::get('database')->article;
	$authorInfo = Zend_Registry::get('database')->author;
?>
<div id="main-content">
    <h2>Article List</h2>
    <ul class="shortcut-buttons-set">
      <li>
      	<a class="shortcut-button" href="<?php echo APPLICATION_URL; ?>/manage/edit-article/id/0"><span> <img src="<?php echo APPLICATION_PUBLIC; ?>/images/admin/icons/pencil_48.png" alt="icon"><br>
        Write an Article </span></a>
      </li>
    </ul>
    <div class="clear"></div>
    <div class="content-box">
      <div class="content-box-header">
        <h3>Content box</h3>
        <div class="clear"></div>
      </div>
      <div class="content-box-content">
        <div class="tab-content default-tab" id="tab1">
          <table>
            <thead>
              <tr>
                <th>ID</th>
                <th>Title</th>
                <th>Author</th>
                <th>Category</th>
                <th>Operation</th>
              </tr>
            </thead>
            <tfoot>
              <tr>
                <td colspan="6">
                  <div class="pagination">
					<a href="<?php echo APPLICATION_URL; ?>/manage/article-list/page/1" title="First Page">&laquo; First</a>
					<a href="<?php echo APPLICATION_URL; ?>/manage/article-list/page/<?php echo $this->page - 1;?>" title="Previous Page">&laquo; Previous</a>
					<?php if ($this->page < 6) {?>
					 	<?php for ($i = 1; $i < 11; $i++) {?>
					 		<?php if ($i == $this->page) {$style = " current";} else {$style = "";}?>
					 		<a href="<?php echo APPLICATION_URL; ?>/manage/article-list/page/<?php echo $i;?>" class="number<?php echo $style;?>"><?php echo $i;?></a>
					 		<?php if ($i == $this->total) {break;}?>
					 	<?php }?>
				 	<?php } else { ?>
				 		<?php for ($i = $this->page - 4; $i < $this->page + 6; $i++) {?>
				 			<?php if ($i == $this->page) {$style = " current";} else {$style = "";}?>
					 		<a href="<?php echo APPLICATION_URL; ?>/manage/article-list/page/<?php echo $i;?>" class="number<?php echo $style;?>"><?php echo $i;?></a>
					 		<?php if ($i == $this->total) {break;}?>
					 	<?php }?>
				 	<?php }?>
					<a href="<?php echo APPLICATION_URL; ?>/manage/article-list/page/<?php echo $this->page + 1;?>" title="Next Page">Next &raquo;</a>
					<a href="<?php echo APPLICATION_URL; ?>/manage/article-list/page/<?php echo $this->total;?>" title="Last Page">Last &raquo;</a>
				  </div>
                  <div class="clear"></div>
                </td>
              </tr>
            </tfoot>
            <tbody>
<?php foreach ($this->articleList as $key => $value) {
	//查询作者名字
	foreach ($this->author as $authorValue) {
		if ($value[$authorInfo->author] == $authorValue[$authorInfo->userid]) {
			$author = $authorValue[$authorInfo->author];
		}
	}
	//查找分类值
	//menu.magazine = "1"
	foreach ($this->categories as $categoryKey => $categoryValue) {
		if ($value['type'] == $categoryValue) {
			$category = $categoryKey;
		}
	}
?>
              <tr>
                <td><?php echo $value[$tableInfo->id];?></td>
                <td><a href="<?php echo APPLICATION_URL; ?>/manage/edit-article/id/<?php echo $value[$tableInfo->id];?>"><?php echo $value[$tableInfo->title];?></a></td>
                <td><?php echo $author;?></td>
                <td><?php echo $category;?></td>
                <td>
                  <a href="<?php echo APPLICATION_URL; ?>/manage/edit-article/id/<?php echo $value[$tableInfo->id];?>" title="Edit"><img src="<?php echo APPLICATION_PUBLIC; ?>/images/admin/icons/pencil.png" alt="Edit" /></a>
                  <a class="deleteAtc" href="###" title="Delete" aid="<?php echo $value[$tableInfo->id];?>"><img src="<?php echo APPLICATION_PUBLIC; ?>/images/admin/icons/cross.png" alt="Delete" /></a>
              </tr>
<?php }?>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="clear"></div>
<?php echo $this->render('/manage/footer.phtml');?>
</div>
</div>
</body>
</html>